<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
<div class="col-md-8">
    <h1>个人信息页</h1>
    <!-- 一个 from 标签，设置 action 为所调用方法的路径，进行后台接口的调用-->
    <form id="info" action="/save" method="post">
        <div class="form-group">
            <label for="name">姓名</label>
            <input type="text" class="form-control" id="name" name="name" placeholder="请输入姓名">
        </div>
        <div class="form-group">
            <label for="studentId">学号</label>
            <input type="text" class="form-control" id="studentId" name="studentId" placeholder="请输入学号">
        </div>
        <div class="form-group">
            <label for="grade">年级</label>
            <input type="text" class="form-control" id="grade" name="grade" placeholder="请输入年级">
        </div>
        <div class="form-group">
            <label for="major">专业</label>
            <input type="text" class="form-control" id="major" name="major" placeholder="请输入专业名称">
        </div>
        <div class="form-group">
            <label for="college">学院</label>
            <input type="text" class="form-control" id="college" name="college" placeholder="请输入学院名称">
        </div>
        <!-- 由于要向后台传入相关的值，所以 button 的 type 设为 submit -->
        <button type="button" class="btn btn-default">确认</button>
    </form>
</div>
</body>
<script>
    $(function(){
        $("button").click(function(){
            var data = $("#info").serialize();
            $.ajax({
                url:"/check",
                type:"post",
                data:data,
                dataType:"json",
                success:function (res){
                    if (res.code!=0){
                        alert(res.msg)
                    }else{
                        $("form").submit()
                        /*$.ajax({
                            url:"/save",
                            type:"post",
                            data:data,
                            dataType:"json",
                            success:function (res){
                                console.log(res)
                                window.location.href="/xuanke.html"
                            }
                        })*/
                    }
                }
            })

        });

    });
</script>
</html>